﻿using LM.Negocio.Objetos;

namespace LM.Repositorios.Maps
{
    using LM.Negocio;
    using System.ComponentModel.DataAnnotations.Schema;
    using System.Data.Entity.ModelConfiguration;

    public class MarcaMap : EntityTypeConfiguration<Marca>
    {
        public MarcaMap()
        {

            // Primary Key
            this.HasKey(t => t.Codigo);

            //this.HasKey(m => m.Codigo);
            this.Property(m => m.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity).HasColumnName("Id");
            //this.Property(m => m.Codigo).HasColumnName("Codigo").IsRequired();
            //this.Property(m => m.Descricao).HasColumnName("Descricao").IsRequired().HasMaxLength(100);


            // Properties
            this.Property(t => t.Codigo)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Descricao)
                .IsRequired()
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("MARCA");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Codigo).HasColumnName("Codigo");
            this.Property(t => t.Descricao).HasColumnName("Descricao");
        }
    }
}
